package Application.Tool;

import Application.Main;
import javafx.scene.Parent;
import javafx.scene.input.MouseEvent;

public class Pen extends Tool{
    private static Pen ins=new Pen();
    public static Pen getInstance(){
        return ins;
    }
    public Main getMain() {
        return main;
    }

    public void setMain(Main main) {
        this.main = main;
    }

    private Main main;
    int blend(int c1, int c2) {
        int ans = 0;
        int a1 = (c1 >> 24) & 0xff;
        int r1 = (c1 & 0x00ff0000) >> 16;
        int g1 = (c1 & 0x0000ff00) >> 8;
        int b1 = (c1 & 0x000000ff);
        int a2 = (c2 >> 24) & 0xff;
        int r2 = (c2 & 0x00ff0000) >> 16;
        int g2 = (c2 & 0x0000ff00) >> 8;
        int b2 = (c2 & 0x000000ff);

        int a = a1 + a2;
        if(a > 255) {
            a = 255;
        }

        int r = (a1 * r1 + (255 - a1) * r2) / 255;
        int g = (a1 * g1 + (255 - a1) * g2) / 255;
        int b = (a1 * b1 + (255 - a1) * b2) / 255;

        ans = (a << 24) | (r << 16) | (g << 8) | b;

        return ans;
    }

    public Parent getToolSettings(){return null;}

    public void onMouseDown(MouseEvent e){}
    public void onMouseMove(MouseEvent e){}
    public void onMouseUp(MouseEvent e){}
}
